//
//  IntroduceViewController.m
//  Shengzhuli
//
//  Created by subook on 2017/9/11.
//  Copyright © 2017年 kamangkeji. All rights reserved.
//

#import "IntroduceViewController.h"
#import "YJWebProgressLayer.h"

@interface IntroduceViewController ()<UIWebViewDelegate>

@property (nonatomic, strong)UIWebView *webView;
@property (nonatomic, strong)YJWebProgressLayer *webProgressLayer;
@end

@implementation IntroduceViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    [self createWebView];
}
- (void)createWebView {
    
    _webView = [[UIWebView alloc] initWithFrame:self.view.frame];
    NSString *urlString = [PublicServer stringByAppendingString:@"/active/value/introduce"];
    _webView.backgroundColor = [UIColor whiteColor];
    NSURL *url = [NSURL URLWithString:urlString];
    NSURLRequest *request = [NSURLRequest requestWithURL:url];
    _webProgressLayer = [[YJWebProgressLayer alloc] init];
    _webProgressLayer.frame = CGRectMake(0, 42, ScreenW, 2);
    
    [self.navigationController.navigationBar.layer addSublayer:_webProgressLayer];
    [self.view addSubview:_webView];
    [_webView loadRequest:request];
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
#pragma mark web delegate
- (void)webViewDidStartLoad:(UIWebView *)webView {
    [_webProgressLayer startLoad];
}

- (void)webViewDidFinishLoad:(UIWebView *)webView {
    [_webProgressLayer finishedLoadWithError:nil];
    self.title = @"规则介绍";
}
- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {
    
    [_webProgressLayer finishedLoadWithError:error];
    
}


- (void)dealloc {
    
    [_webProgressLayer closeTimer];
    [_webProgressLayer removeFromSuperlayer];
    _webProgressLayer = nil;
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
